package com.peak.gateway.tcp;

import reactor.netty.DisposableServer;
import reactor.netty.tcp.TcpServer;

/**
 * @author likai
 * @date 2021/2/20 15:03
 * @email likai9376@163.com
 * @desc
 */
public class TcpServerDemo {

    public static void main(String[] args) {
        DisposableServer disposableServer = TcpServer.create()
                //.doOnBind(startMetrics->startMetrics.)
                // .doOnBound(startedMetrics)
                //.doOnUnbound(stopMetrics)
                .host("127.0.0.1")
                .port(1234)
                .bind()
                .block();


        disposableServer.channel().writeAndFlush("hello");

        Thread awaitThread = new Thread("server") {
            @Override
            public void run() {
                disposableServer.onDispose().block();
            }

        };
        awaitThread.setDaemon(false);
        awaitThread.start();





    }
}
